package com.cn.intelligence.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.intelligence.pojo.EUDataGridResult;
import com.cn.intelligence.pojo.TaotaoResult;
import com.cn.intelligence.pojo.TbMUser;
import com.cn.intelligence.service.SytemUserService;
/**
 * 系统管理员信息
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/user/")
public class SytemUserController {

	@Autowired
	SytemUserService sytemUserService;
	/**
     * 查询用户列表
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("list")
    @ResponseBody
    public EUDataGridResult getSystemUserList(Integer page,Integer rows,String selectUser){
    	EUDataGridResult euDataGridResult = new EUDataGridResult();
    	if(selectUser!=null && !"".equals(selectUser)){
    		  euDataGridResult =sytemUserService.getSystemUser(selectUser,page,rows);	
    	}else{
    		 euDataGridResult =sytemUserService.getSystemUserList(page,rows);	
    	}
        return euDataGridResult;
    }
    /**
     * 添加和修改用户信息
     * @param tbMuser
     * @return
     */
    @RequestMapping(value = "andOrUpdateUser",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult andOrUpdateUser(TbMUser tbMuser){
    	
    	TaotaoResult taotaoResult= sytemUserService.insertTbMuser(tbMuser);
    	return taotaoResult;
    }
    /**
     * 删除用户
     * @param tbMuser
     * @return
     */
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult deleteUser(Long ids[]){
  
    	TaotaoResult taotaoResult= sytemUserService.deleteUser(ids);
    	return taotaoResult;
    }
    /**
     * 查询用户
     * @param tbMuser
     * @return
     */
    @RequestMapping(value = "selectUser",method = RequestMethod.POST)
    @ResponseBody
    public EUDataGridResult selectUser(String username){
        EUDataGridResult euDataGridResult =sytemUserService.getSystemUser(username,1,10);
        return euDataGridResult;
    }
    
    
}
